<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
</head>
<body>
<h1>Login</h1>

<div style="text-align: center">

    <label for="username">账号：</label>
    <input id="username" type="text">

    <label for="password">密码：</label>
    <input id="password" type="password">

    <input type="button" id="sub" value="登录">
</div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script>
    $('#sub').click(function () {
        var username = $('#username').val(),
        password = $('#password').val()

        if (!username || !password){
            console.log('请输入账号密码')
        } else {
            $.ajax({
                url: '/login',
                data: {username: username, password: password},
                success: function (res) {
                    console.log(res)
                },
                error: function () {
                    alert('error')
                }
            })
        }

    })
</script>
</html>